﻿<UserControl x:Class="AppFabric.Admin.Clients.Desktop.UserControls.SearchCacheItemUserControl"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:lex="clr-namespace:WPFLocalizeExtension.Extensions;assembly=WPFLocalizeExtension"
             xmlns:uc="clr-namespace:AppFabric.Admin.Clients.Desktop.UserControls"
             xmlns:fluent="clr-namespace:Fluent;assembly=Fluent"
             mc:Ignorable="d" 
             d:DesignHeight="400" d:DesignWidth="600">
    <UserControl.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Skins/MainSkin.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*" />
        </Grid.ColumnDefinitions>
        <Grid Grid.Row="0" Grid.Column="0">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="Auto" />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Grid.Row="0" Grid.Column="0" Text="{lex:LocText Key=SearchPatternTitle, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" />
            <fluent:TextBox Grid.Row="0" Grid.Column="1" Text="{Binding SearchPattern}" MinWidth="250"/>
            <TextBlock Grid.Row="1" Grid.Column="0" Text="{lex:LocText Key=NamedCacheTitle, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" />
            <fluent:ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{Binding NamedCaches}" MinWidth="250" SelectedValue="{Binding SelectedNamedCache, Mode=OneWayToSource}" />
            <fluent:Button Grid.Row="2" Grid.Column="1"
                           Header="{lex:LocText Key=SearchHeader, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}"
                           SizeDefinition="Middle"
                           Icon="/Skins/search.ico"
                           LargeIcon="/Skins/search.ico"
                           Command="{Binding SearchCommand}" />
        </Grid>
        <ListView Grid.Row="1" Grid.Column="0" ItemsSource="{Binding SearchResults}">
            <ListView.Resources>
                <DataTemplate x:Key="DeleteButtonTemplate">
                    <Button Style="{StaticResource TabImageButton20x20Style}"
                            Command="{Binding RelativeSource={RelativeSource AncestorType={x:Type uc:SearchCacheItemUserControl}}, Path=DataContext.RemoveItemCommand}"
                            CommandParameter="{Binding}">
                        <Image Source="/Skins/remove.png" />
                    </Button>
                </DataTemplate>
            </ListView.Resources>
            <ListView.View>
                <GridView>
                    <GridView.Columns>
                        <GridViewColumn Header="{lex:LocText Key=CacheKeyHeader, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" DisplayMemberBinding="{Binding Key}" />
                        <GridViewColumn Header="{lex:LocText Key=NamedCacheHeader, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" DisplayMemberBinding="{Binding NamedCache}" />
                        <GridViewColumn Header="{lex:LocText Key=RegionHeader, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" DisplayMemberBinding="{Binding Region}"/>
                        <GridViewColumn Header="{lex:LocText Key=DeleteHeader, Dict=Resources.UIResources, Assembly=AppFabric.Admin.Clients.Desktop}" CellTemplate="{StaticResource DeleteButtonTemplate}" />
                    </GridView.Columns>
                </GridView>
            </ListView.View>
        </ListView>
    </Grid>
</UserControl>
